package com.futureway.test.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.futureway.test.dao.CourseRespository;
import com.futureway.test.entity.Course;
import com.futureway.test.service.CourseService;

@Service
public class CourseServiceImpl implements CourseService {

	@Autowired
	private CourseRespository courseRespository;

	@Override
	public Integer save(String courseName) {
		Course course = new Course();
		course.setCourseName(courseName);
		course = courseRespository.saveAndFlush(course);
		return course.getId();
	}

	@Override
	public List<Course> findAll() {
		return courseRespository.findAll();
	}

	@Override
	public Course get(Integer id) {
		return courseRespository.getOne(id);
	}

}
